package com.topisv.tms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.topisv.tms.entity.PerformanceFee;
import com.topisv.tms.entity.QueryParamHolder;
import com.topisv.tms.repository.PerformanceFeeDao;
import com.topisv.tms.service.base.BaseService;

//Spring Bean的标识.
@Component
// 默认将类中的所有public函数纳入事务管理.
@Transactional(readOnly = true)
public class PerformanceFeeService extends BaseService{

	@Autowired
	private PerformanceFeeDao performanceFeeDao;
	
	@Autowired
	private JdbcTemplate jdbcTemplate;

	public PerformanceFee getPerformanceFee(Long id) {
		return performanceFeeDao.findOne(id);
	}
	
	public PerformanceFee findPerformanceFee(String warehouseCode,String customerCode,String optype) {
		return performanceFeeDao.findPerformanceFee(warehouseCode, customerCode, optype);
	}

	@Transactional(readOnly = false)
	public void savePerformanceFee(PerformanceFee entity) {
		performanceFeeDao.save(entity);
	}

	@Transactional(readOnly = false)
	public void deletPeformanceFee(Long id) {
		performanceFeeDao.delete(id);
	}

	public List<PerformanceFee> getAllPerformanceFee() {
		return (List<PerformanceFee>) performanceFeeDao.findAll();
	}
	
	public Page<PerformanceFee> getPerformanceFee(QueryParamHolder paramHolder) {
		return findByJson(paramHolder, performanceFeeDao, PerformanceFee.class);
	}
	
}
